/*
 * PsInputWriter.h
 *
 *  Created on: 2018年8月9日
 *      Author: zhengboyuan
 */

#ifndef PSINPUTWRITER_H_
#define PSINPUTWRITER_H_

#include "MediaWriter.h"
#include "SharedPtr.h"
#include "PsParser.h"


namespace av
{

class PsInputWriter : public MediaWriter
{
public:
    explicit PsInputWriter(MediaFileFormat fileFormat);
    virtual ~PsInputWriter();

	virtual bool open(const char* filename, const MFormat& fmt);

	virtual void close();

	virtual bool isOpen();

	virtual bool getFormat(MFormat& fmt);

	virtual bool writeVideo(uint8_t* data, int size, int64_t pts, int flags);

	virtual bool writeAudio(uint8_t* data, int size, int64_t pts, int flags);

	virtual int getDuration();

	virtual int64_t getByteLength();

	virtual bool setFile(const char* filepath);

	virtual bool setOutputAudioCodec(int codecId);

	virtual void setListener(MediaWriterListener* listener);

	virtual bool setMeta(const char* key, const char* value, int size);

protected:
	bool writeData(uint8_t* data, int size, int64_t pts, int flags);

	void onFormatReady();

protected:
	typedef	std::shared_ptr< MediaWriter >		MediaWriterPtr;

	MediaWriterPtr	m_writer;
	PsParser	m_psParser;
	std::string	m_filename;
	MediaFormat	m_format;

};

} /* namespace av */

#endif /* PSINPUTWRITER_H_ */
